package datastructure.deck;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * User: Lars Christian Ersly
 * Date: 03-06-11
 * Time: 10:29
 */
public class Deck {
    private List<Card> cards;

    public final int defaultDeckSize = 84;

    /**
     * creates a new shuffled default sized datastructure.deck
     */
    public Deck(){
        cards = new ArrayList<Card>();
        createFullDeck();
        shuffleDeck();
//        System.out.println(toString());
    }

    /**
     * Creates a standard Robo Rally datastructure.deck
     */
    private void createFullDeck(){
        int priority = 0;
        for(Card.cardTypes type : Card.cardTypes.values()){
            for(int i = 0; i < Card.getDefRatio(type); i++){
                priority++;
                cards.add(new Card(type, priority * 10));
            }
        }
    }

    /**
     * Shuffles this deck
     */
    public void shuffleDeck(){
        Collections.shuffle(cards);
    }

    /**
     * @return an List with all cards
     */
    public List<Card> getCards() {
        return cards;
    }

    @Override
    public String toString() {
        String deck = "";
        for(Card c : cards){
            deck += c.getCardType() + " " + c.getPriority() + "\n";
        }
        return deck;
    }
}
